home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr11
/
mbug9307.zip
/
HACKER.TXT
< prev
next >
Wrap
Text File
|
1993-07-01
|
6KB
|
124 lines
The Frugal Hacker
Bob Stephan
hacker n A person who enjoys exploring the details of programmable
systems and how to stretch their capabilities, as opposed to most
users who prefer to learn only the minimum necessary. (The "New
Hacker's Dictionary", MIT Press, 1991.)
BACK TO BATCH. I keep getting distracted from my main purpose of
discussing the "Out of environment space" problem that can arise
when trying to run batch files that create useful Environment
variables. This month I will be able to include another
installment.
To recap, when a secondary copy of the command processor (usually
COMMAND.COM) is invoked, the Environment block is shrunk down to a
minimum size by MS-DOS. This usually happens when you run batch
files from one of the many menu or shell programs such as PC Shell,
Xtree, etc. Only the command processor knows how to run batch
programs so in order for a menu or shell to run a batch program, it
has to start up a copy of COMMAND.COM or another command processor
such as 4DOS.COM. The environment space problem is almost entirely
a problem of MS-DOS since other versions appear to be more
intelligent. In my testing I have found that DR DOS appears to use
the original size of the Environment block as the default size for
secondary copies, and 4DOS is the best of all with a method to
specify what you want as the default. If you use either DR DOS or
4DOS you probably don't need to worry about this problem if you
have set your SHELL= command in CONFIG.SYS and/or your 4DOS
parameters correctly.
If you tried the last suggestion I made about modifying your
COMSPEC variable to include /E:1024, you have probably found that
it didn't always work, if it worked at all. This method depends on
some intelligent parsing on the part of the program that "shells
out" to DOS, i.e. invokes the secondary command processor. Not
many programs or versions of DOS are prepared to deal with this
method.
If you happen to have the book "Harnessing DOS 6.0: Batch File and
Command Macro Power" (Menefee & Anis, Bantam, 1993) that I review
in this issue, there is a good dicussion of the problem and some
suggested solutions beginning on page 288. If you want to get an
advance start on some of the information and methods I will cover
in this and subsequent columns, check out this book.
USE A DUMMY. One of the considerations in deciding on the solution
you want to use is whether the batch files will be run only on your
personal computer, or if you might be programming them to run on
other computers such as setting up systems for several computers in
an office environment. If the batch files are for your personal
use only, you have more options than if they might be operating in
a DOS system that you cannot control.
The simplest solution for your own system is to reserve the amount
of Environment space you want to maintain with dummy variables.
This is easily done by adding one or more SET commands to your
AUTOEXEC.BAT, or to the batch file that starts your menu program.
With each SET command you can reserve up to about 120 bytes of
Environment space for future use. Your batch files can then clear
out as much space as they need by simply deleting one or more of
the dummy variables.
To establish the dummy variables, you might want to create a
separate batch file that can be called from other batch files as
needed. Call the file SETDUM.BAT or whatever you want, and just
include one or more statements such as SET DUMMY1=111111. . .11111,
where the entire statement can be up to the DOS limit of 127
characters. If you think you need more than 120 bytes of free
space, add a SET DUMMY2=222. . .222, etc. Then in your
AUTOEXEC.BAT, or your batch file that starts your menu program,
simply include the statement CALL SETDUM, using whatever name you
have given to your version of the file. To free up the reserved
space start your application batch files with the statement SET
DUMMY1=. You can add more for DUMMY2 and others if needed.
To avoid having to modify any of your existing batch files, and to
make sure that the dummy variables are only cleared when needed,
you can use another batch file. You might call this file
RUNDUM.BAT, and its purpose will be to clear out the dummy
variables and run your application batch file. RUNDUM.BAT will
consist of two lines:
SET DUMMY1=
%1 %2 %3 %4 %5 %6 %7 %8 %9
Then, whenever you need to clear out the dummy variables before
running your application batch file you enter:
RUNDUM [yourbatch] [parameters]
In particular, when you want to run a batch file from within your
shell or menu program, you tell the shell or menu to use the above
command. For example, if you set up a menu item to run MYPROG.BAT
with a parameter of FILENAME.DOC, then you tell your menu to run
RUNDUM MYPROG FILENAME.DOC.
USING GET. My batch enhancer, GET.EXE, makes extensive use of the
Environment block. If the "Out of environment space" problem is
due to your use of GET, there is an even simpler method you can
use. Instead of using some other name for your dummy variable use
the name GET. In SETDUM.BAT you can use a statement such as SET
GET=gggg. . .ggggg, where you can use up to 127 characters for the
statement. The rest is automatic. When GET needs the Environment
space, it will automatically clear out the GET variable and resuse
the space. You will not need to change your menu items or create
the RUNDUM.BAT file. A similar method might work with other
programs that require free space in the Environment block. [To be
continued]
DEFINITIONS OF THE MONTH With apologies to Stan Kelly-Bootle,
author ot The Devil's DP Dictionary, McGraw-Hill, 1981.
There are three things a man must do
Before his life is done;
Write two lines in MS BATCH,
And make the buggers run.
Bob Stephan welcomes comments and questions that The Frugal Hacker
can respond to. He can be reached on Internet
(bob.stephan@nitelog.com), NITELOG (408-655-1096), CRICKET
(408-373-3773), Compu$erve (72357,2276), Plodigy (FNGC05A), or
snail mail at the MBUG-PC address.